<template>
  <div style="min-width:1050px">
    <div class="leftContainer">
      <div class="cutCrads">
        <div v-show="SlicesDateListFromDatabase.length===0">暂无资源</div>
        <div v-for="item in SlicesDateListFromDatabase" :key="item.id" class="oneOfCutCards">
          <div class="left">
            <div class="top">
              <div class="qustionType">类型：</div>
              <div class="qustionTypeContent">{{ item.type===20?"图片":item.module }}</div>
            </div>
            <div v-if="item.type===20" class="middle">
              <img :src="imgSrc+item.content" style="width: 250px;" >
            </div>
            <div v-else class="middle">
              {{ item.content }}
            </div>

            <div class="bottom">
              <div class="updateTime">更新时间：</div>
              <div class="updateTimeContent">{{ item.createTime.split("T")[0] }}</div>
              <div v-if="item.type===20" class="title">图片来源：</div>
              <div v-else class="title"> 教案标题：</div>
              <div class="titleContent">{{ item.type===20?item.instructionName:item.title }}</div>
            </div>
          </div>
          <div class="right">
            <add-to-package-button
              :resourceType="'lGoal'"
              :resourceID="item.id.toString()"
            ></add-to-package-button>
          </div>
          <div style="clear:both"></div>
        </div>
      </div>
      <div class="block">
        <el-pagination
          :page-count="pages"
          :current-page="ShowInfo.pageNum"
          :page-size="ShowInfo.pageSize"
          layout="prev, pager, next"
          @current-change="handleCurrentChange">
        </el-pagination>
      </div>
    </div>
    <div class="rightContainer">
      <el-dropdown @command="handleCommand">
        <span class="el-dropdown-link">
          选择类型<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="1">教学目标</el-dropdown-item>
          <el-dropdown-item command="2">教学重难点</el-dropdown-item>
          <el-dropdown-item command="3">教学准备</el-dropdown-item>
          <el-dropdown-item command="4">其他</el-dropdown-item>
          <el-dropdown-item command="20">图片</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>

  </div>
</template>

<script>
import AddToPackageButton from '@/components/Buttons/AddToPackageButton.vue'
import { getTeachingPlaneSlices } from '@/api/slices'
import { imgSrc } from '@/config/minio'
export default {
  components: { AddToPackageButton },
  data: function() {
    return {
      SlicesDateListFromDatabase: [],
      // 获取展示列表对象
      ShowList: [],
      // 总页数
      pages: null,
      id: null,
      // 接口参数
      ShowInfo: {
        // 当前的页数
        pageNum: 1,
        // 每页显示的条数
        pageSize: 5,
        type: null,
        keyword: null
      },
      imgSrc: imgSrc
    }
  },
  watch: {

  },
  created() {
    this.getShowList()
  },
  methods: {

    getsearchInput(val) {
      this.ShowInfo.keyword = val || null
      this.ShowInfo.type = null
      this.getShowList()
    },
    // 获取展示列表
    async getShowList() {
      const { data: result } = await getTeachingPlaneSlices(this.ShowInfo)// 解构数据

      this.SlicesDateListFromDatabase = result.data.instructionPlanClips
      this.pages = result.data.pages
    },
    // 监听页码值改变的事件
    handleCurrentChange(newPage) {
      this.ShowInfo.pageNum = newPage
      this.getShowList()
    },
    // 下拉菜单选择事件
    handleCommand(command) {
      this.ShowInfo.type = command
      this.ShowInfo.pageNum = 1
      this.getShowList()
    }
  }
}
</script>

<style scoped>
.leftContainer{
  float: left;
}
.rightContainer{
  color:rgb(34, 52, 110) ;
  min-width: 100px;
  margin-left: 40px;
  font-family: 'Roboto', sans-serif;
  font-size: 30px;
  font-weight: bolder;
  float: right;
}
.cutCrads{
  min-height: 230px;
  min-width: 900px;
}
.oneOfCutCards{
  background-color: rgb(254, 254, 254);
  width: 900px;
  min-height: 150px;
  margin-bottom: 20px;
  grid-column: 3;
  box-shadow: 1px 1px 5px rgb(233, 226, 252);
  padding-bottom: 10px;
  position: relative;
  /* 触发BFC, 防止float塌陷*/
  overflow : hidden;
}

.oneOfCutCards:hover{
  box-shadow: 2px 2px 10px rgb(233, 226, 252);
  transform:translateY(1px);
}
.left{
  width:90%;
  float: left;
  left:0;
  height: 100%;
}
.right{

  top:15%;
  right: 0;
  width: 10%;
  height: 100%;
  float: right;
  /* transform:translateY(-50%);
  top:50%; */

  padding-left: 22px;
  position: absolute;

}
.top{
  height: 60px;
  width: 100%;
}
.qustionType{
  padding-left:20px ;
  padding-top: 20px;
  display: inline-block;
  font-family:  'Roboto', sans-serif;
  font-size: 18px;
  font-weight: bold;
  color: rgb(34, 52, 110);
}
.qustionTypeContent{
  display: inline-block;
  font-size: 17px;

  left: 80px;

  color: rgb(34, 52, 110);
}
.middle{
  padding-left: 20px;
  padding-bottom: 50px;
  width:100%;
  height: auto;
  min-width: 100px;
  color: rgb(34, 52, 110);
}
.bottom{
  position:absolute;
  left:20px;
  width: 90%;
  bottom:10px;
}
.updateTime{
  display: inline-block;
  color: rgb(149, 149, 149);
  font-size: 14px;
  vertical-align: middle;
}
.title{
  display: inline-block;
  color: rgb(149, 149, 149);
  font-size: 14px;
  padding-left: 20px;
  vertical-align: middle;
}
.titleContent{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  max-width: 560px;
  display: inline-block;
  color: rgb(149, 149, 149);
  font-size: 13px;
}
.updateTimeContent {
  padding-top: 1px;
  display: inline-block;
  vertical-align: middle;
  color: rgb(149, 149, 149);
  font-size: 13px;

}

/* 分页区域 */
.block{
  margin-bottom: 50px;
}
.el-pagination {
    text-align: center;
}
.el-pagination /deep/ .el-pager  li.active{
  color:rgb(134, 98, 241) ;
}
.el-pagination /deep/ .el-pager :hover{
  color:rgb(134, 98, 241) ;
}

/* 筛选下拉框区域 */
.el-dropdown-link {
    cursor: pointer;
  }
.el-icon-arrow-down {
    font-size: 12px;
  }
.el-dropdown-menu__item:not(.is-disabled):hover{

      background-color: rgb(241, 243, 252) !important;
      color: #333333 !important;
}
</style>
